<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/jsp/taglibs-struts2.jsp" %>

<form action="flightOrderAction!selfOrder.action" method="post">
<div class="right">
<div class="right600"><h2 class="r201">航班信息</h2><h2 class="r202"/></div>

<input type="hidden" name="passengersNum" value="<c:out value="${passengersNum}"/>"/>

<c:forEach var="price" items="${flightPriceList}">

<input type="hidden" name="<c:out value="${price.company.twocode}_price"/>" value="<c:out value="${price.price}"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_tax"/>" value="<c:out value="${price.tax}"/>"/>

<div class="right600b"><h2 class="r203"><input type="radio" value="<c:out value="${price.company.twocode}"/>" name="company"/><c:out value="${price.company.comChineseName}"/></h2>
<h2 class="r204">票价<c:out value="${price.price}"/>元 税金<c:out value="${price.tax}"/>元 总计<font color="#cc0000"><b><c:out value="${price.price+price.tax}"/>元</b></font></h2>
</div>
<div class="r205"><h2 class="r50">去向</h2><h2 class="r50">航班号</h2><h2 class="r100">城市对</h2><h2 class="r100">起飞时间</h2><h2 class="r100">降落时间</h2><h2 class="r100">航班班期</h2><h2 class="r50">舱位</h2>
</div>
<c:set var="toFlight" value="${price.toFlight}"/>
<c:set var="backFlight" value="${price.backFlight}"/>

<c:forEach var="tf" items="${toFlight}" varStatus="toStatus">
<c:if test="${toStatus.first}"><div class="r206"><h2 class="r50"><font color="#009900">去程</font></h2></c:if>
<h2 class="r50"><c:out value="${tf.planeInfo.planeno}"/></h2>
<h2 class="r100"><c:out value="${tf.planeInfo.departure.airportChineseName}"/>-<c:out value="${tf.planeInfo.destination.airportChineseName}"/></h2>
<h2 class="r100"><fmt:formatDate value="${tf.takeoffDate}" pattern="yyyy-MM-dd"/></h2>
<h2 class="r100"><fmt:formatDate value="${tf.putdownDate}" pattern="yyyy-MM-dd"/></h2>
<h2 class="r100">周<c:forEach var="day" items="${tf.avaiableDays}" varStatus="dayStatus"><c:if test="${day}"><c:out value="${dayStatus.index+1}"/>,</c:if></c:forEach></h2>
<h2 class="r50"><c:out value="${tf.bunk}"/>仓</h2>
</div>
<input type="hidden" name="<c:out value="${price.company.twocode}_to_offdate_${toStatus.index}"/>" value="<fmt:formatDate value="${tf.takeoffDate}" pattern="yyyy-MM-dd"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_to_downdate_${toStatus.index}"/>" value="<fmt:formatDate value="${tf.putdownDate}" pattern="yyyy-MM-dd"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_to_departure_${toStatus.index}"/>" value="<c:out value="${tf.planeInfo.departure.airportThreeCode}"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_to_dest_${toStatus.index}"/>" value="<c:out value="${tf.planeInfo.destination.airportThreeCode}"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_to_planeno_${toStatus.index}"/>" value="<c:out value="${tf.planeInfo.planeno}"/>"/>
</c:forEach>

<c:forEach var="tf" items="${backFlight}" varStatus="toStatus">
<c:if test="${toStatus.first}"><div class="r206"><h2 class="r50"><font color="#009900">回程</font></h2></c:if>
<h2 class="r50"><c:out value="${tf.planeInfo.planeno}"/></h2>
<h2 class="r100"><c:out value="${tf.planeInfo.departure.airportChineseName}"/>-<c:out value="${tf.planeInfo.destination.airportChineseName}"/></h2>
<h2 class="r100"><fmt:formatDate value="${tf.takeoffDate}" pattern="yyyy-MM-dd"/></h2>
<h2 class="r100"><fmt:formatDate value="${tf.putdownDate}" pattern="yyyy-MM-dd"/></h2>
<h2 class="r100">周<c:forEach var="day" items="${tf.avaiableDays}" varStatus="dayStatus"><c:if test="${day}"><c:out value="${dayStatus.index+1}"/>,</c:if></c:forEach></h2>
<h2 class="r50"><c:out value="${tf.bunk}"/>仓</h2>
</div>
<input type="hidden" name="<c:out value="${price.company.twocode}_back_offdate_${toStatus.index}"/>" value="<fmt:formatDate value="${tf.takeoffDate}" pattern="yyyy-MM-dd"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_back_downdate_${toStatus.index}"/>" value="<fmt:formatDate value="${tf.putdownDate}" pattern="yyyy-MM-dd"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_back_departure_${toStatus.index}"/>" value="<c:out value="${tf.planeInfo.departure.airportThreeCode}"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_back_dest_${toStatus.index}"/>" value="<c:out value="${tf.planeInfo.destination.airportThreeCode}"/>"/>
<input type="hidden" name="<c:out value="${price.company.twocode}_back_planeno_${toStatus.index}"/>" value="<c:out value="${tf.planeInfo.planeno}"/>"/>
</c:forEach>

</c:forEach>

<div><input type="submit" name="createOrder" value="预定" onclick="return submitCreateOrder()"/></div>

</div>
</form>

<script type="text/javascript">
function submitCreateOrder() {
var inputs = document.getElementsByTagName("input");
var radios = [];
for(var i = 0; i < inputs.length; i ++) {
  if(inputs[i].type == 'radio') {
    radios.push(inputs[i]);
  }
}
var bSel = false;
for(i = 0; i < radios.length; i ++) {
  if(radios[i].checked == true) {
    bSel = true;
    break;
  }
}

if(!bSel) {
  alert("请选择航班");
  return false;
}
return true;
}
</script>